package com.iqik.ioc.utils;

import com.iqik.ioc.anno.Service;

import java.sql.Connection;
import java.sql.SQLException;

@Service
public class ConnectionUtils {

    private ThreadLocal<Connection> threadLocal = new ThreadLocal<>();

    public Connection getCurrentThreadConn() throws SQLException {
        Connection connection = threadLocal.get();
        if (connection == null) {
            System.out.println("get connection new!!!!!!!");
            connection = DruidUtils.getInstance().getConnection();
            threadLocal.set(connection);
        }
        return connection;
    }
}
